export default {
	weblogReport(type = 'default', name = '', payload = {}) {
		const db = this.database();
		const weblogCol = db.collection('weblog');
		const getReportId = () => {
			return Math.floor(
				Math.pow(16, 7) * (Math.random() * 15 + 1)
			).toString(16);
		};
		const date = new Date();
		const data = {
			type,
			name,
			payload,
			deviceId: wf.getModule('reporter').getDeviceId(),
			reportId: getReportId(),
			timeStamp: date.getTime(),
			ua: window.navigator.userAgent,
			localTime: date.toLocaleString(),
			dateString: date.toString(),
			url: window.location.href,
			pageId: window.location.href.split('?')[0],
			queryString: window.location.href.split('?')[1],
		};
		// console.log('weblogReport', data);
		return weblogCol.add(data);
	},
};
